// 模块化

// 1. 导入 路由 相关的包
import Vue from "vue";
import VueRouter from "vue-router";

// 2. 在vue中，使用使用vue的插件，都需要调用Vue.use()
Vue.use(VueRouter);

// 3.引入路由所映射的组件
import Layout from "@/views/layout";
import Home from "@/views/home";
import Search from "@/views/Search";
import Play from "@/views/Play";

// 4. 创建路由对象 --- 传入规则
const router = new VueRouter({
  routes: [
    {
      path: "/",
      redirect: "/layout",
    },
    {
      path: "/layout", // 一级路由 主页面
      component: Layout,
      redirect: "/layout/home",
      children: [
        {
          path: "home", // 二级路由 首页
          component: Home,
        },
        {
          path: "search", // 二级路由  搜索页面
          component: Search,
        },
      ],
    },
    {
      path: "/play",
      component: Play,
    },
  ],
});

// 5. 向外暴露
export default router;
